package tlias.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import tlias.service.LoginService;
import tlias.pojo.Emp;
import tlias.pojo.LoginResponse;
import tlias.pojo.Result;

@RestController
@RequestMapping("/login")
@Slf4j
public class LoginController {
    private final LoginService loginService;
    public LoginController(LoginService loginService) {
        this.loginService = loginService;
    }
    @PostMapping
    public Result login(@RequestBody Emp emp){
        log.info("登录成功");
        LoginResponse loginResponse = loginService.loginCheck(emp);
        if (loginResponse != null){
            return Result.success(loginResponse);
        }
        return Result.error("用户名或密码错误");
    }
}
